// Filename: router.js
define([
  'jQuery',
  'Underscore',
  'Backbone',
  'views/home/main',
  'views/projects/list',
  'views/users/list',
  'views/etudiant/profil',
  'views/etudiant/absence',
  'views/etudiant/list'
], function($, _, Backbone, mainHomeView, projectListView, userListView ){
  var AppRouter = Backbone.Router.extend({
    routes: {
      // Define some URL routes
      '/projects': 'showProjects',
      '/users': 'showUsers',
      '/etudiants': 'showEtudiants',
      '/etudiant/:id': 'showEtudiant',
	  "/:route/:action/:id": "loadView",
      
      // Default
      '*actions': 'defaultAction'
    },
    showProjects: function(){
      // Call render on the module we loaded in via the dependency array
      // 'views/projects/list'
      projectListView.render();
    },
	showEtudiants: function(){
      // Call render on the module we loaded in via the dependency array
      // 'views/projects/list'
      etudiantListView.render();
    },
	showEtudiant: function(id){
      // Call render on the module we loaded in via the dependency array
      etudiantView.render();
    },
      // As above, call render on our loaded module
      // 'views/users/list'
    showUsers: function(){
      userListView.render();
    },
    defaultAction: function(actions){
      // We have no matching route, lets display the home page 
      mainHomeView.render(); 
    }
  });

  var initialize = function(){
    var app_router = new AppRouter;
    Backbone.history.start();
  };
  return { 
    initialize: initialize
  };
});
